package com.tbsoft.ehr.action;

import java.util.ArrayList;
import java.util.List;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.tbsoft.ehr.login.LoginInfo;
import com.tbsoft.ehr.model.AttachFile;
/**
 * ＠desc 公共action
 * @author vastdream
 *
 */
public class BaseAction extends ActionSupport {
	/**
	 * 默认200代表成功
	 */
	private String statusCode="200";
	/**
	 * 返回消息 
	 */
	private String message="操作成功";
	private String navTabId;
	private String rel;
	private String callbackType;
	private String forwardUrl;
	private String confirmMsg;
	
	/**
	 * 分页
	 */
	public final static int PAGE_SHOW_COUNT = 17;
	private int pageNum = 1;
	private int numPerPage = 17;
	private int totalCount = 0;
	private int pageNumShown=1;
	
	
	public int getPageNumShown() {
		return pageNumShown;
	}
	public void setPageNumShown(int pageNumShown) {
		this.pageNumShown = pageNumShown;
	}
	public int getPageNum() {
		return pageNum;
	}
	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}
	public int getNumPerPage() {
		return numPerPage;
	}
	
	public int getTotalCount() {
		return totalCount;
	}
	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}
	public String getStatusCode() {
		return statusCode;
	}
	public void setStatusCode(String statusCode) {
		this.statusCode = statusCode;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public String getNavTabId() {
		return navTabId;
	}
	public void setNavTabId(String navTabId) {
		this.navTabId = navTabId;
	}
	public String getRel() {
		return rel;
	}
	public void setRel(String rel) {
		this.rel = rel;
	}
	public String getCallbackType() {
		return callbackType;
	}
	public void setCallbackType(String callbackType) {
		this.callbackType = callbackType;
	}
	public String getForwardUrl() {
		return forwardUrl;
	}
	public void setForwardUrl(String forwardUrl) {
		this.forwardUrl = forwardUrl;
	}
	public String getConfirmMsg() {
		return confirmMsg;
	}
	public void setConfirmMsg(String confirmMsg) {
		this.confirmMsg = confirmMsg;
	}
	private static final long serialVersionUID = 1L;
	public String add(){
		return "add";
	}
	public String browse(){
		return "browse";
	}
	private List<AttachFile> attachFileList = new ArrayList<AttachFile>();

	public synchronized List<AttachFile> getAttachFileList() {
		return attachFileList;
	}
	public synchronized void setAttachFileList(List<AttachFile> attachFileList) {
		this.attachFileList = attachFileList;
	}
	
	/**
	 * 获取当前的用户id
	 * 
	 * @return
	 */
	public String readUserId() {
		LoginInfo li = (LoginInfo)ActionContext.getContext().getSession().get("loginInfo");
		if(li!=null){			
			return li.getUserId();
		} else{
			throw new RuntimeException("用户已过期，请重新登录");
		}
		
	}
	
	/**
	 * 表单提交失败时返回
	 * 
	 * @param msg
	 * @return
	 */
	protected String errorReturn(String msg){
		setStatusCode("300");
		setMessage(msg);
		return ERROR;
	}
}
